package merchant.service;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;
import merchant.dao.MerchantDAO;
import merchant.dao.MerchantSettlementDetail;

import hackathon1212.ServletPojoAdapter;

public class ShowSettlements extends ServletPojoAdapter {
	private static final long serialVersionUID = 7004794558559793322L;
	
	protected List<MerchantSettlementDetail> getBusinessMethod(Map<String, String[]> params){		
		try {
			final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
			final String merchantNumber = params.get("merchantNumber")[0];
			final Date fromInclusiveDate = sdf.parse(params.get("fromDate")[0]);			
			final Date toExclusiveDate = sdf.parse(params.get("toDate")[0]);			
			return MerchantDAO.get().findSettlements(merchantNumber, fromInclusiveDate, toExclusiveDate);
		} catch (ParseException e) {
			//Mucky, but gets the job done
			throw new RuntimeException(e);
		}

	}
	
}
